package cn.jbooter.shiro.autoconfigure;

import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import cn.jbooter.shiro.autoconfigure.config.ShiroAnnotationConfiguration;
import cn.jbooter.shiro.autoconfigure.config.ShiroCacheManagerConfiguration;
import cn.jbooter.shiro.autoconfigure.config.ShiroConfiguration;
import cn.jbooter.shiro.autoconfigure.config.ShiroRememberMeConfiguration;
import cn.jbooter.shiro.autoconfigure.config.ShiroWebConfiguration;
import cn.jbooter.shiro.autoconfigure.config.SpringSessionRestShiroFilterConfiguration;
import cn.jbooter.shiro.autoconfigure.properties.IShiroProperties;

/**
 * 安全配置(基于shiro实现)
 * 
 * @author HeJian
 *
 */
@Configuration
@EnableConfigurationProperties(value = { IShiroProperties.class })
@ConditionalOnProperty(prefix = "spring.shiro", name="enabled", havingValue="true")
@Import({
	SpringSessionRestShiroFilterConfiguration.class,
	ShiroCacheManagerConfiguration.class,
	ShiroConfiguration.class,
	ShiroWebConfiguration.class,
	ShiroAnnotationConfiguration.class,
	ShiroRememberMeConfiguration.class
})
public class ShiroAutoConfigure {
    
	private static final Logger logger = LoggerFactory.getLogger(ShiroAutoConfigure.class);

	
    /**
	 * shiro lifecycle配置
	 * @return
	 */
	@Bean("lifecycleBeanPostProcessor")
	public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
        return new LifecycleBeanPostProcessor();
    }
}
